﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xant.FlowEngine.Core;

namespace Xant.FlowEngine.Factory
{
    public class ProcessFactory
    {
        public static ProcessInstance CreateProcess(ProcessTemplate template)
        {
            template.Validate();
            MainProcess process = new MainProcess() { Name = template.Name };
            foreach (var activity in template.Activities)
            {
                var newActivity = activity.Copy();
                process.AddActivity(newActivity);
            }
            foreach (var transition in template.Transitions)
            {
                var trans = process.AddTransition(transition.From.Code, transition.To.Code);
                trans.Label = transition.Label;
            }
            return process;
        }

        public static AbstractProcess CreateProcess(SubprocessActivity subprocessActivity)
        {
            throw new NotImplementedException();
        }

    }
}
